<?php
define('EmpireCMSAdmin','1');
require_once("../class/connect.php");
require_once("../class/db_sql.php");
require_once("../class/functions.php");
require_once("../class/user.php");
require_once("../class/page_obj.php");

$link=db_connect();
$empire=new mysqlquery();
$act_db="phome_ecms_actives";
$reg_db="phome_jat_act_registration";
$act_id=$_REQUEST['act_id'];
if(!$act_id){
	echo "<div class='data-error'>系统错误</div>";
	exit();
}
$info=DbTouch($act_db,array('id'=>$act_id));
//$suncNum=DbTouch($act_db,array('id'=>$act_id)," count(id) as num ");
$sql="select 
				count(id) as total,
				sum(case when status=1 then 1 else 0 end) as wait,
				sum(case when status=2 then 1 else 0 end) as deny,
				sum(case when status=11 then 1 else 0 end) as allow
		from $reg_db
		where act_id='{$act_id}'";
	$nums=$empire->fetch1($sql);
	//print_r($nums);
if(!$info){
	echo "<div class='data-error'>无此记录！</div>";
	exit();
}
$is_my_act=$info['userid']==$lguserid?true:false;//标识我是否是活动发起人；
$page=$_REQUEST['page'];
$page=new page_obj($page,array("itemnum"=>5,"border"=>6,"row_count"=>$nums['total']));
$page_start=$page->arr_temp['start'];
$page_end=$page->arr_temp['end'];
$page_current=$page->current_page;
$limit_str=$page->get_limit_str();
$regs=DbTouchAll($reg_db,array('act_id'=>$act_id),"*",$limit_str);
?>
<table  class="tb_member_list" style="width:1000px;">
<tr><td>头像</td><td>用户名</td><td>真实姓名</td><td>电话</td><td>性别</td><td>所在学校或公司</td><td>人数</td><td>紧急联系人</td><td>紧急联系方式</td><td>备注</td><td>保险号</td><td>申请时间</td><td>状态</td><td>操作</td></tr>
<?php
if($regs){
foreach($regs as $key=>$vals)
{
	$is_run=true;
	$u=getUserInfo($vals['uid']);
	$head=getUserHead($u["userpic"],69,69);
	$is_show=(!empty($lguserid) && $lguserid==$info['userid'])?true:false;
	$statusM=array("1"=>"act-wait","2"=>"act-deny","11"=>"act-allow");
	$statusTxt=array("1"=>"等待","2"=>"拒绝","11"=>"通过");
	$lineClass="act_reg_{$vals[id]}";
	$statusClass=$statusM[$vals['status']]." act-status";
	//var_dump($info['userid']);
?>
<tr class="<?=$lineClass?>" status='<?=$vals['status']?>'>
	<td>
		<a href='<?=$public_r['newsurl']."e/member/sp/?uid=".$vals['uid']?>'>
			<img src="<?=$head?>" width="30"/></a>
	</td>	
	<td><a href='<?=$public_r['newsurl']."e/member/sp/?uid=".$vals['uid']?>'><?=$u["nickname"]?></a></td>
	<td><?=$is_show?$vals["truename"]:"***";?></td>	
	<td><?=$is_show?$vals["tel"]:"***";?></td>
	<td><?=$vals["sex"]=2?"男":"女"?></td>
	<td><?=$is_show?$vals["corporation"]:"***";?></td>
	<td><?=$is_show?$vals["num"]:"***";?></td>
	<td><?=$is_show?$vals["aid_person"]:"***";?></td>
	<td><?=$is_show?$vals["aid_tel"]:"***";?></td>
	<td><?=$is_show?$vals["remark"]:"***";?></td>
	<td><?=$is_show?$vals["insurance_id"]:"***";?></td>
	<td><?=nl2br(date("Y-m-d \r H-i-s",$vals["time"]))?></td>
	<td class="<?=$statusClass?>"><?=$statusTxt[$vals["status"]]?></td>
	<td><?php

		if($is_my_act){		
			echo"<a href='#' class='act-allow-btn' act_id='{$vals[id]}' >批准</a>";
			echo"<a href='#' class='act-deny-btn'  act_id='{$vals[id]}' >拒绝</a>";
			
		}else{
			echo "<a href='{$public_r['newsurl']}e/member/sp/?uid={$vals['uid']}' target='_blank'>查看</a>";
		}	
	
	?></td>
</tr>

<?php }?>
<?

echo "<tr><td colspan='13' class='' style='text-align:left;color:#888;text-align:center;'><ul class='page-list'>";
for( $i=$page_start;$i<=$page_end;$i++){
	echo "<li><span class=".($i==$page_current?"current":"page")." onclick='loadThePageM(\"{$i}\")'>{$i}</span></li>";
}
echo "</ul></td></tr>";

	echo "<tr>
		<td colspan='13' class='' style='text-align:left;color:#888;text-align:center;'>
		共：<span style='color:#000'>".$nums['total']."</span>人报名&nbsp;&nbsp;
		通过：<span style='color:green'>".$nums['allow']."</span>人&nbsp;&nbsp;
		拒绝：<span style='color:red'>".$nums['deny']."</span>人&nbsp;&nbsp;
		还有：<span style='color:green'>".(($info['person_num']-$nums['total'])>=0?($info['person_num']-$nums['total']):0)."</span>个名额</td></tr>";

}else{
	echo "<tr><td colspan='13' class='no-data'>暂无数据！</td></tr>";
}
//}


?>
</table>
